package cloud.xiguapi.ubas.controller;

import cloud.xiguapi.ubas.common.ApiResult;
import cloud.xiguapi.ubas.common.Pager;
import cloud.xiguapi.ubas.entity.KafkaHotItems;
import cloud.xiguapi.ubas.service.IKafkaHotItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 大大大西西瓜皮🍉
 * date: 2021-5-24 下午 04:16
 * desc:
 */
@RestController
@RequestMapping("/kafka-hot-items")
public class KafkaHotItemsController {

    private final IKafkaHotItemsService<KafkaHotItems> kafkaHotItemsService;

    @Autowired
    public KafkaHotItemsController(IKafkaHotItemsService<KafkaHotItems> kafkaHotItemsService) {
        this.kafkaHotItemsService = kafkaHotItemsService;
    }

    @GetMapping("/analysis")
    public ApiResult<Object> analysis() {
        return kafkaHotItemsService.analysis();
    }

    @GetMapping("/select/{current}/{size}")
    public ApiResult<Pager<KafkaHotItems>> selectFileHotItemsPage(@PathVariable long current, @PathVariable long size) {
        if (current <= 0) {
            current = 1;
        }
        if (size <= 0) {
            size = 10;
        }
        return kafkaHotItemsService.selectPage(current, size);
    }
}
